Rouhani will pay a working visit to China and attend the summit of the China and Russia-led security bloc the Shanghai Cooperation Organization, the ministry said.
It did not give exact dates for his visit, but the summit is scheduled to be held on the second weekend of June in the northern Chinese city of Qingdao.
Iran is currently an observer member of the Shanghai Cooperation Organization, though it has long sought full membership.
“Our hope is that China and Iran will have close consultation on the basis of observing the deal and push forward development of bilateral cooperation,” Chinese deputy foreign minister Zhang Hanhui said at a briefing.
“We should together look into how to avoid major disruption of joint projects between the two sides,” he added.
Russia has previously argued that with Western sanctions against Tehran lifted, it could finally become a member of the bloc which also includes four ex-Soviet Central Asian republics, Pakistan and India.
The 2015 agreement between Iran and world powers lifted international sanctions on Tehran. In return, Iran agreed to restrictions on its nuclear activities, increasing the time it would need to produce an atom bomb if it chose to do so.
Since U.S. President Donald Trump withdrew the United States this month, calling the agreement deeply flawed, European states have been scrambling to ensure Iran gets enough economic benefits to persuade it to stay in the deal.
China has also strongly supported the deal and is one of its signatories.